package ua.at.javac.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="journal")
public class Journal implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="journal_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	int id;
	
	@Column(name="uptodate")
	java.sql.Date uptodate;
	
	@OneToMany(mappedBy = "id", fetch = FetchType.LAZY)
	Site site;

	@OneToMany(mappedBy = "id", fetch = FetchType.LAZY)
	Set<Period> period;

	@Column(name="cloudiness")
	int cloudiness;

	@Column(name="temperature")
	int temperature;
	
	@Column(name="precipitation")
	float precipitation;
	
	@Column(name="humidity")
	int humidity;
	
	@Column(name="pressure")
	int pressure;
	
	@Column(name="windSpeed")
	int windSpeed;
	
	@Column(name="wind_id")
	int wind_id;
	
	@Column(name="forecast_day")
	int forecast_day;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public java.sql.Date getUptodate() {
		return uptodate;
	}

	public void setUptodate(java.sql.Date update) {
		this.uptodate = update;
	}

	public int getCloudiness() {
		return cloudiness;
	}

	public void setCloudiness(int cloudiness) {
		this.cloudiness = cloudiness;
	}

	public int getTemperature() {
		return temperature;
	}

	public void setTemperature(int temperature) {
		this.temperature = temperature;
	}

	public float getPrecipitation() {
		return precipitation;
	}

	public void setPrecipitation(float precipitation) {
		this.precipitation = precipitation;
	}

	public int getHumidity() {
		return humidity;
	}

	public void setHumidity(int humidity) {
		this.humidity = humidity;
	}

	public int getPressure() {
		return pressure;
	}

	public void setPressure(int pressure) {
		this.pressure = pressure;
	}

	public int getWindSpeed() {
		return windSpeed;
	}

	public void setWindSpeed(int windSpeed) {
		this.windSpeed = windSpeed;
	}

	public int getWind_id() {
		return wind_id;
	}

	public void setWind_id(int wind_id) {
		this.wind_id = wind_id;
	}

	public int getForecast_day() {
		return forecast_day;
	}

	public void setForecast_day(int forecast_day) {
		this.forecast_day = forecast_day;
	}

	public Site getSite() {
		return site;
	}
	
	public void setSite(Site site) {
		this.site = site;
	}
	
	public Set<Period> getPeriod() {
		return period;
	}
	
	public void setPeriod(Set<Period> period) {
		this.period = period;
	}

	public String getTemperatureFile() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getCloudinessFile() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getPressureFile() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getPrecipitationFile() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getWindDirection() {
		// TODO Auto-generated method stub
		return null;
	}

	public java.sql.Date getCity() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		return "Journal [id=" + id + ", uptodate=" + uptodate + ", site="
				+ site + ", period=" + period + ", cloudiness=" + cloudiness
				+ ", temperature=" + temperature + ", precipitation="
				+ precipitation + ", humidity=" + humidity + ", pressure="
				+ pressure + ", windSpeed=" + windSpeed + ", wind_id="
				+ wind_id + ", forecast_day=" + forecast_day + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Journal other = (Journal) obj;
		if (cloudiness != other.cloudiness)
			return false;
		if (forecast_day != other.forecast_day)
			return false;
		if (humidity != other.humidity)
			return false;
		if (id != other.id)
			return false;
		if (period == null) {
			if (other.period != null)
				return false;
		} else if (!period.equals(other.period))
			return false;
		if (Float.floatToIntBits(precipitation) != Float
				.floatToIntBits(other.precipitation))
			return false;
		if (pressure != other.pressure)
			return false;
		if (site == null) {
			if (other.site != null)
				return false;
		} else if (!site.equals(other.site))
			return false;
		if (temperature != other.temperature)
			return false;
		if (uptodate == null) {
			if (other.uptodate != null)
				return false;
		} else if (!uptodate.equals(other.uptodate))
			return false;
		if (windSpeed != other.windSpeed)
			return false;
		if (wind_id != other.wind_id)
			return false;
		return true;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + cloudiness;
		result = prime * result + forecast_day;
		result = prime * result + humidity;
		result = prime * result + id;
		result = prime * result + ((period == null) ? 0 : period.hashCode());
		result = prime * result + Float.floatToIntBits(precipitation);
		result = prime * result + pressure;
		result = prime * result + ((site == null) ? 0 : site.hashCode());
		result = prime * result + temperature;
		result = prime * result
				+ ((uptodate == null) ? 0 : uptodate.hashCode());
		result = prime * result + windSpeed;
		result = prime * result + wind_id;
		return result;
	}
}
